<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hash;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class ListController extends Controller
{
    public function getList()
    {
    	$a = DB::table('order')->get();

    	// dd($a);
        return view('admin.order.list',['ld'=>$a]);
    }

    public function getEdit($uid)
    {
    	// echo 222;
    	$res = DB::table('order')->where('id',$uid)->first();
    	
    	// dd($res);
    	return view('admin.order.edit',['res'=>$res]);
    }

    public function postUpdate(Request $request)
    {
    	// dd($request->all());
    	$b = $request->input('id');
    	// dd($a);
    	$a = $request->only('itime','stime','send','address','payment');
    	$res = DB::table('order')->where('id',$b)->update($a);
    	if($res)
   		{
   			return redirect('/admin/order/list')->with('success','修改成功');
   		}else{
   			return back()->with('error','分类修改失败');
   		}
    }
    public function postDelete(Request $request)
	{
		// 获取id
		$id = $request->input('id');
		// dd($id);
		// 执行删除
		$res = DB::table('order')->where('id',$id)->delete();
		if($res){
			echo 1;
		}else{
			echo 0;
		}
	}
}
